From: Adrian Vovk Date: Tue, 20 Jan 2026 05:04:57 +0000 (-0500) Subject: systemActions: Separate CanReboot from CanShutdown X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~26^2~1^2~23 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=fecd860d2c34238deacf5ca83f2d55fb58d606b3;p=gnome-shell.git systemActions: Separate CanReboot from CanShutdown The reboot actions and shutdown actions are independent, and might have independent availability. It's perfectly valid for a system administrator to configure a system where one action is available and the other isn't. This commit separates the availability of these actions, and allows them to be independently shown/hidden There's a corresponding change in gnome-session Part-of: --- diff --git a/data/dbus-interfaces/org.gnome.SessionManager.xml b/data/dbus-interfaces/org.gnome.SessionManager.xml index 74a3a2e55..628a4693b 100644 --- a/data/dbus-interfaces/org.gnome.SessionManager.xml +++ b/data/dbus-interfaces/org.gnome.SessionManager.xml @@ -8,6 +8,9 @@ + + + diff --git a/js/misc/systemActions.js b/js/misc/systemActions.js index eb358e37a..814746217 100644 --- a/js/misc/systemActions.js +++ b/js/misc/systemActions.js @@ -83,6 +83,8 @@ const SystemActions = GObject.registerClass({ this._canHavePowerOff = true; this._powerOffNeedsAuth = false; + this._canHaveReboot = true; + this._rebootNeedsAuth = false; this._canHaveSuspend = true; function tokenizeKeywords(keywords) { @@ -184,11 +186,15 @@ const SystemActions = GObject.registerClass({ this._lockdownSettings.connect(`changed::${DISABLE_LOCK_SCREEN_KEY}`, () => this._updateLockScreen()); - this._lockdownSettings.connect(`changed::${DISABLE_LOG_OUT_KEY}`, - () => this._updateHaveShutdown()); + this._lockdownSettings.connect(`changed::${DISABLE_LOG_OUT_KEY}`, () => { + this._updateHaveShutdown(); + this._updateHaveReboot(); + }); - this._screenSaverSettings.connect(`changed::${RESTART_ENABLED_KEY}`, - () => this._updateHaveShutdown()); + this._screenSaverSettings.connect(`changed::${RESTART_ENABLED_KEY}`, () => { + this._updateHaveShutdown(); + this._updateHaveReboot(); + }); this.forceUpdate(); @@ -269,6 +275,7 @@ const SystemActions = GObject.registerClass({ _sessionUpdated() { this._updateLockScreen(); this._updatePowerOff(); + this._updateReboot(); this._updateSuspend(); this._updateMultiUser(); } @@ -278,6 +285,7 @@ const SystemActions = GObject.registerClass({ // settings and Polkit policy - we don't get change notifications for the // latter, so their value may be outdated; force an update now this._updateHaveShutdown(); + this._updateHaveReboot(); this._updateHaveSuspend(); } @@ -364,8 +372,27 @@ const SystemActions = GObject.registerClass({ this._loginScreenSettings.get_boolean(DISABLE_RESTART_KEY)); this._actions.get(POWER_OFF_ACTION_ID).available = this._canHavePowerOff && !disabled; this.notify('can-power-off'); + } - this._actions.get(RESTART_ACTION_ID).available = this._canHavePowerOff && !disabled; + async _updateHaveReboot() { + try { + const [availability] = await this._session.CanRebootAsync(); + this._canHaveReboot = availability !== GnomeSession.ActionAvailability.UNAVAILABLE; + this._rebootNeedsAuth = availability === GnomeSession.ActionAvailability.CHALLENGE; + } catch { + this._canHaveReboot = false; + this._rebootNeedsAuth = false; + } + this._updateReboot(); + } + + _updateReboot() { + const disabled = (Main.sessionMode.isLocked && + !this._screenSaverSettings.get_boolean(RESTART_ENABLED_KEY)) || + (Main.sessionMode.isLocked && this._rebootNeedsAuth) || + (Main.sessionMode.isGreeter && + this._loginScreenSettings.get_boolean(DISABLE_RESTART_KEY)); + this._actions.get(RESTART_ACTION_ID).available = this._canHaveReboot && !disabled; this.notify('can-restart'); }